package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.Tag;
import cn.wolfcode.trip.base.mapper.TagMapper;
import cn.wolfcode.trip.base.service.ITagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TagServiceImpl  implements ITagService {
    @Autowired
    private TagMapper tagMapper;

    @Override
    public void saveOrUpdate(Tag tag) {
        if (tag.getId() == null) {
            tagMapper.insert(tag);
        } else {
            tagMapper.updateByPrimaryKey(tag);
        }
    }

    @Override
    public List<Tag> getStrategyId(Long strategyId) {
        List<Tag> tag = tagMapper.getStrategyId(strategyId);

        return tag;
    }

    @Override
    public List<Tag> listAll() {
        return tagMapper.selectAll();
    }

    @Override
    public void insertMyTags(String myTag) {
        tagMapper.insertMyTags(myTag);
    }

    @Override
    public Long selectByMyTagsName(String myTag) {
        Long num = tagMapper.selectByMyTagsName(myTag);
        return num;
    }

    @Override
    public void insertRelation(Long num, Long strategyId) {
        tagMapper.insertRelation(num, strategyId);
    }


}
